package com.shilei.strategy;

import com.shilei.Bullet;
import com.shilei.GameModel;
import com.shilei.Tank;
import com.shilei.decorator.RectDecorator;

import java.io.Serializable;

/**
 * @description: 默认开火策略
 * @author: 81271
 * @date: 2020-04-12 16:38
 */
public class DefaultFireStrategy implements FireStrategy , Serializable {
    @Override
    public void fire(Tank tank) {
        int bX = tank.getX() + Tank.WIDTH/2 - Bullet.WIDTH/2;
        int bY = tank.getY() + Tank.HEIGHT/2 - Bullet.HEIGHT/2;

        GameModel.getInstance().gameObjectList.add(new RectDecorator(new Bullet(bX, bY, tank.getDir(), tank.getGroup())));
    }
}
